[DefaultEvent("ValueChanged"), Designer("System.Web.UI.Design.WebControls.HiddenFieldDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), SupportsEventValidation, PersistChildren(false), NonVisualControl, ControlValueProperty("Value"), ParseChildren(true), DefaultProperty("Value")]
public class HiddenField : Control, IPostBackDataHandler
{
    // Fields
    private static readonly object EventValueChanged = new object();

    // Events
    [WebSysDescription("HiddenField_OnValueChanged"), WebCategory("Action")]
    public event EventHandler ValueChanged
    {
        add
        {
            base.Events.AddHandler(EventValueChanged, value);
        }
        remove
        {
            base.Events.RemoveHandler(EventValueChanged, value);
        }
    }

    // Methods
    protected override ControlCollection CreateControlCollection()
    {
        return new EmptyControlCollection(this);
    }

    [EditorBrowsable(EditorBrowsableState.Never)]
    public override void Focus()
    {
        throw new NotSupportedException(SR.GetString("NoFocusSupport", new object[] { base.GetType().Name }));
    }

    protected virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
    {
        base.ValidateEvent(this.UniqueID);
        string str = this.Value;
        string str2 = postCollection[postDataKey];
        if (!str.Equals(str2, StringComparison.Ordinal))
        {
            this.Value = str2;
            return true;
        }
        return false;
    }

    protected internal override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        if (!this.SaveValueViewState)
        {
            this.ViewState.SetItemDirty("Value", false);
        }
    }

    protected virtual void OnValueChanged(EventArgs e)
    {
        EventHandler handler = (EventHandler) base.Events[EventValueChanged];
        if (handler != null)
        {
            handler(this, e);
        }
    }

    protected virtual void RaisePostDataChangedEvent()
    {
        this.OnValueChanged(EventArgs.Empty);
    }

    protected internal override void Render(HtmlTextWriter writer)
    {
        string uniqueID = this.UniqueID;
        if (this.Page != null)
        {
            this.Page.VerifyRenderingInServerForm(this);
            this.Page.ClientScript.RegisterForEventValidation(uniqueID);
        }
        writer.AddAttribute(HtmlTextWriterAttribute.Type, "hidden");
        if (uniqueID != null)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Name, uniqueID);
        }
        if (this.ID != null)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID);
        }
        string str2 = this.Value;
        if (str2.Length > 0)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Value, str2);
        }
        writer.RenderBeginTag(HtmlTextWriterTag.Input);
        writer.RenderEndTag();
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
    {
        return this.LoadPostData(postDataKey, postCollection);
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    void IPostBackDataHandler.RaisePostDataChangedEvent()
    {
        this.RaisePostDataChangedEvent();
    }

    // Properties
    [DefaultValue(false), EditorBrowsable(EditorBrowsableState.Never)]
    public override bool EnableTheming
    {
        get
        {
            return false;
        }
        set
        {
            throw new NotSupportedException(SR.GetString("NoThemingSupport", new object[] { base.GetType().Name }));
        }
    }

    private bool SaveValueViewState
    {
        get
        {
            if (((base.Events[EventValueChanged] == null) && this.Visible) && !(base.GetType() != typeof(HiddenField)))
            {
                return false;
            }
            return true;
        }
    }

    [EditorBrowsable(EditorBrowsableState.Never), DefaultValue("")]
    public override string SkinID
    {
        [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
        get
        {
            return string.Empty;
        }
        set
        {
            throw new NotSupportedException(SR.GetString("NoThemingSupport", new object[] { base.GetType().Name }));
        }
    }

    [WebSysDescription("HiddenField_Value"), WebCategory("Behavior"), DefaultValue(""), Bindable(true)]
    public virtual string Value
    {
        get
        {
            string str = (string) this.ViewState["Value"];
            if (str == null)
            {
                return string.Empty;
            }
            return str;
        }
        set
        {
            this.ViewState["Value"] = value;
        }
    }
}
 